import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
  GetPreview = '/ledger/project-ledger/preview',
  ImportLedger = '/ledger/project-ledger/import',
  GetCompanyLedger = '/ledger/company-ledger',
  GetProjectLedger = '/ledger/project-ledger',
  GetCompanyLedgerByNb = '/ledger/company-ledger/internal',
  GetCompanyList = '/company/name-list',
  DelCompany = '/company/name-list',
  AddCompany = '/company/name-list',
  SearchCompany = '/company/search',
  CheckCompany = '/company/name-list/check',
  DelTz = '/ledger/project-ledger',
}

// 获取项目台账统计信息
export function getPreview(mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetPreview },
    {
      errorMessageMode: mode,
    },
  );
}

// 导入项目台账
export function importLedger(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.ImportLedger, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取台账供应商列表
export function getCompanyLedger(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetCompanyLedger, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取项目台账列表
export function getProjectLedger(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetProjectLedger, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取内部供应商列表
export function getCompanyLedgerByNb(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetCompanyLedgerByNb, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 获取供应商名单列表（分页）
export function getCompanyList(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.GetCompanyList, params },
    {
      errorMessageMode: mode,
    },
  );
}

// 删除供应商名单
export async function deleteCompany(id: string, mode: ErrorMessageMode = 'message') {
  return defHttp.delete<number>(
    {
      url: Api.DelCompany + `/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

// 新增供应商名单
export function addCompany(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    { url: Api.AddCompany, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 检测公司名单情况
export function checkCompany(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
      { url: Api.CheckCompany, params },
      {
        errorMessageMode: mode,
      },
  );
}
// 查询公司供应商名单情况
export function searchCompany(params: any, mode: ErrorMessageMode = 'message') {
  return defHttp.get(
    { url: Api.SearchCompany, params },
    {
      errorMessageMode: mode,
    },
  );
}
// 删除台账合作信息
export async function deleteTz(id: string | number, mode: ErrorMessageMode = 'message') {
  return defHttp.delete<number>(
    {
      url: Api.DelTz + `/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}
